package com.luhui.codereview.enums


/**
 * @author  luhui
 * @date  2019/11/3 19:38
 * @version 1.0
 */
enum class CodeReviewLevelEnum(val levelCode: Int, val desc:String) {
    SLIGHT(0,"轻微"),
    GENERAL(1,"一般"),
    SERIOUSNESS(2,"严重");

    companion object {
        fun getAllEnumValues():Array<String>{
            return CodeReviewLevelEnum.values().map { e->e.desc }.toTypedArray()
        }

        fun getCodeByDesc(desc:String):Int?{
            for (value in values()) {
                if(value.desc == desc){
                    return value.levelCode
                }
            }
            return null
        }

        fun getDescByCode(code:Int):String{
            for (value in values()) {
                if(value.levelCode == code){
                    return value.desc
                }
            }
            return code.toString()
        }
    }
}